﻿<!DOCTYPE html>
<html>
<head>
    <title></title>
    <link href="/style/rightdirectory.css" rel="stylesheet" />
    <script src="/script/config.js"></script>
</head>

<body>
    <h5>购买产品分利配置</h5>
    <div class="form-body">
        <div class="form-horizontal  hide" id="form">

        </div>
    </div>
</body>
</html>
<script type="text/html" id="tp-form">  
    <div id="tem">
        <div class="form-group">
            <label class="col-sm-3">第一级是合伙人分利</label>
            <div class="col-md-4 col-sm-10">
                <input type="text" class="form-control" data-form="PartnerLevelOneCommission" placeholder="第一级是合伙人分利" value="{{PartnerLevelOneCommission}}">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3">第二级是合伙人分利</label>
            <div class="col-md-4 col-sm-10">
                <input type="text" class="form-control" data-form="PartnerLevelTwoCommission" placeholder="第二级是合伙人分利" value="{{PartnerLevelTwoCommission}}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3">第三级以及无限级给合伙人分利</label>
            <div class="col-md-4 col-sm-10">
                <input type="text" class="form-control" data-form="PartnerLevelOtherCommission" placeholder="第三级以及无限级给合伙人分利" value="{{PartnerLevelOtherCommission}}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3">普通第一级分利</label>
            <div class="col-md-4 col-sm-10">
                <input type="text" class="form-control" data-form="CommonLevelOneCommission" placeholder="普通第一级分利" value="{{CommonLevelOneCommission}}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3">普通第二级分利</label>
            <div class="col-md-4 col-sm-10">
                <input type="text" class="form-control" data-form="CommonLevelTwoCommission" placeholder="普通第二级分利" value="{{CommonLevelTwoCommission}}">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3">购买人身份</label>
            <div class="col-sm-2 col-sm-1">
                <label class="radio-reset">
                    <input type="radio" name="n" data-form="CustomerIdentity" value="1" {{CustomerIdentity|radio_checked 1}}>
                    <span>普通用户</span>
                </label>
                <label class="radio-reset">
                    <input type="radio" name="n" data-form="CustomerIdentity" value="2" {{CustomerIdentity|radio_checked 2}}>
                    <span>会员</span>
                </label>
            </div>
        </div>

        <div class="form-group">
            <div class="col-sm-offset-3 col-sm-10">
                <button type="button" id="btn-submit" class="btn btn-primary">保存</button>
                <button type="button" class="btn" onclick="window.history.go(-1)">退出</button>
            </div>
        </div>
    </div>
</script>
<link href="/script/valid/css/tr.css" rel="stylesheet" /><!--判断如：PlatformName格式-->
<script src="/script/valid/form-valid.js?v=2018"></script>
<script> 
    $(function () {
        var id = QueryPageUrlString("v");//获取传来的参数
        var formValidEvent;
        var formValidInit = function () {  //修改前的判断
            var formValidData = [
                {
                    key: "PayPartnerLevelOneCommissionName",
                    datatype: "money",
                    nullmsg: "不能为空哦",
                    errormsg: "请输入数字哦！"
                },
                {
                    key: "PartnerLevelTwoCommission",
                    datatype: "money",
                    nullmsg: "不能为空哦",
                    errormsg: "请输入数字哦！"
                },
                {
                    key: "PartnerLevelOtherCommission",
                    datatype: "money",
                    nullmsg: "不能为空哦",
                    errormsg: "请输入数字哦！"
                },
                {
                    key: "CommonLevelOneCommission",
                    datatype: "money",
                    nullmsg: "不能为空哦",
                    errormsg: "请输入数字哦！"
                },
                {
                    key: "CommonLevelTwoCommission",
                    datatype: "money",
                    nullmsg: "不能为空哦",
                    errormsg: "请输入数字哦！"
                },
                
            ];
            formValidEvent = $("#tem").formValid(formValidData); 
        }

        $.http.json("customerbuyproductcommissionconfig/find", {   //发请求，显示出数据
            Id: id
        }, {
                pass: function (data) {
                  
                    $("#form").templateRender({ el: "tp-form", data: data });//渲染模板，要先渲染才能获值
                    formValidInit();
                },
                error: function (d) {
                    console.log(d);
                }
            });
       
        $("#form").on("click", "#btn-submit", function () { //保存修改的数据
            if (!formValidEvent.check()) { return; }
            var apiUrl = "customerbuyproductcommissionconfig/upd";
            $("#form").ajaxFormSubmit(apiUrl, {
                pass: function (d) {
                    $.msgSucceed(d.Errmsg);
                    return
                },
                error: function (d) {
                    console.log(d)
                    $.msgFall(d.Errmsg);
                }
            }, { addData: { Id:id } })
            return
        });
    });
</script>
